import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules ,longLimtVal} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {UploadTypeEnum} from "/@/components/Form/src/jeecg/components/JUpload";
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '收据编号',
    align:"center",
    dataIndex: 'receiptnum'
  },
   {
    title: '企业名称',
    align:"center",
    dataIndex: 'enterprise'
   },
  {
    title: '付款单位',
    align:"center",
    dataIndex: 'payunit'
  },
  {
    title: '款项内容',
    align:"center",
    dataIndex: 'billcontent'
  },

  {
    title: '收据类型',
    align:"center",
    dataIndex: 'type'
  },

   {
    title: '收款金额',
    align:"center",
    dataIndex: 'bill'
   },
  {
    title: '收款日期',
    align:"center",
    dataIndex: 'receivedate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '电话',
    align:"center",
    dataIndex: 'phone'
  },
  {
    title: '流水号',
    align:"center",
    dataIndex: 'lsh'
  },
  {
    title: '经办人',
    align:"center",
    dataIndex: 'dealperson_dictText'
  },
  {
    title: '经办状态',
    align:"center",
    dataIndex: 'status'
  },
   {
    title: '收据文件路径',
    align:"center",
    dataIndex: 'filepath',
    slots: { customRender: 'filepathSlot' },
   },

  {
    title: '一级管理人',
    align:"center",
    dataIndex: 'owner1_dictText'
  },
  {
    title: '一级状态',
    align:"center",
    dataIndex: 'state1'
  },
  {
    title: '一级分发时间',
    align:"center",
    dataIndex: 'passtime1',
  },

  {
    title: '二级管理人',
    align:"center",
    dataIndex: 'owner2_dictText'
  },
  {
    title: '二级状态',
    align:"center",
    dataIndex: 'state2'
  },

  {
    title: '分配经办人时间',
    align:"center",
    dataIndex: 'passusetime',
  },

];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "企业",
      field: 'enterprise',
      component: 'JInput',
      colProps: {span: 6},
 	},
  {
    label: "收款日期",
    field: "receivedate",
    component: 'RangePicker',
    componentProps: {
      valueType: 'Date',
    },
    colProps: {span: 6},
  },
  {
    label: "收据类型",
    field: 'type',
    component: 'JDictSelectTag',
    colProps: {span: 6},
    componentProps:{
      dictCode:"receipt_type"
    }
  },

  {
    label: '一级状态',
    field: 'state1',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"receipt_owner_state"
    }

  },
  {
    label: '二级管理人',
    field: 'owner2',
    component: 'JSelectUser',
    componentProps:{
      isRadioSelection:true
    },
  },
  {
    label: '二级状态',
    field: 'state2',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"receipt_owner_state"
    }
  },
  {
    label: "分配经办人",
    field: 'dealperson',
    component: 'JSelectUser',
    colProps: {span: 6},
  },
	{
      label: "经办状态",
      field: 'status',
      component: 'JDictSelectTag',
    componentProps:{
      dictCode:"receipt_state"
    },
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '收据编号',
    field: 'receiptnum',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入收据编号!',
          validator: (_, value) => {
            return longLimtVal(value,16)
          },
        },
      ];
    },
  },
  {
    label: '企业',
    field: 'enterprise',
    component: 'JSearchSelect',
    componentProps:{
      // isRadioSelection:true
      dict:"DB_QYZLB,MC,MC",
      async:true,
      pageSize:5,
    },
  },
  {
    label: '付款单位',
    field: 'payunit',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,25)
          },
        },
      ];
    },
  },
  {
    label: '款项内容',
    field: 'billcontent',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,100)
          },
        },
      ];
    }
  },
  {
    label: '电话',
    field: 'phone',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,16)
          },
        },
      ];
    }
  },
  {
    label: "收据类型",
    field: 'type',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'receipt_type'
    }
  },

  {
    label: '收款金额',
    field: 'bill',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,14)
          },
        },
      ];
    }
  },
  {
    label: '收款日期',
    field: 'receivedate',
    component: 'DatePicker',
    componentProps:{
      valueFormat:"YYYY-MM-DD HH:mm:ss",
      format:"YYYY-MM-DD HH:mm:ss"
    }
  },
  {
    label: '流水号',
    field: 'lsh',
    component: 'Input',
    dynamicDisabled:true,
  },
  {
    field: 'filepath',
    component: 'JUpload',
    helpMessage: '最多上传1个文件',
    label: '收据文件',
    componentProps: { maxCount: 1 ,bizPath: 'receipt'},
  },

  {
    label: '分配经办人',
    field: 'dealperson',
    component: 'JSelectUser',
    componentProps:{
      isRadioSelection:true
    }
  },
  {
    label: '经办状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:'receipt_state',
    },
  },
  {
    label: '分配经办人时间',
    field: 'passusetime',
    component: 'DatePicker',
    componentProps:{
      valueFormat:"YYYY-MM-DD HH:mm:ss",
      format:"YYYY-MM-DD HH:mm:ss"
    }
  },


  {
    label: '一级管理人',
    field: 'owner1',
    component: 'JSelectUser',
    dynamicDisabled:true,
  },
  {
    label: '一级状态',
    field: 'state1',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"receipt_owner_state"
    }

  },
  {
    label: '一级分发时间',
    field: 'passtime1',
    component: 'DatePicker',
    componentProps:{
      valueFormat:"YYYY-MM-DD HH:mm:ss",
      format:"YYYY-MM-DD HH:mm:ss"
    }
  },
  {
    label: '一级核销时间',
    field: 'endtime1',
    component: 'DatePicker',
    componentProps:{
      valueFormat:"YYYY-MM-DD HH:mm:ss",
      format:"YYYY-MM-DD HH:mm:ss"
    }
  },
  {
    label: '二级管理人',
    field: 'owner2',
    component: 'JSelectUser',
    componentProps:{
      isRadioSelection:true
    },
  },
  {
    label: '二级状态',
    field: 'state2',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"receipt_owner2_state"
    }
  },


  {
    label: '二级分发时间',
    field: 'passtime2',
    component: 'DatePicker',
    componentProps:{
      valueFormat:"YYYY-MM-DD HH:mm:ss",
      format:"YYYY-MM-DD HH:mm:ss"
    }
  },

  {
    label: '二级核销时间',
    field: 'endtime2',
    component: 'DatePicker',
    componentProps:{
      valueFormat:"YYYY-MM-DD HH:mm:ss",
      format:"YYYY-MM-DD HH:mm:ss"
    }
  },




	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
